<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Products extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->model('Mproduct');
		   $this->load->library('pagination');
		   $this->lang->load('home', 'vietnamese');
	}
	
	function index()
	{
		
		$data['title']='Sản phẩm';
		$data['main']= 'productpage';
	
		$this->load->view('template/index',$data);
	}
	function detail($id)
	{
			$lg = 'vn';
			if($lg == 'en')
				$lang = 2;
			else
				$lang =1;
			$data['title']='Sản phẩm';
			$data['main']='product_detail';
		$data['result']= $this->Mproduct->get_prod_detail($id,$lang);
		$this->load->view('template/index',$data);
	
	}
	function category($id,$page="")
	{
		$lg = 'vn';
			if($lg == 'en')
				$lang = 2;
			else
				$lang =1;
		$limit = 9;

		$config['base_url'] = site_url().'/product/category/';

		$config['first_link'] = 'First';

		$config['last_link'] = 'Last';

		$config['next_link'] = '&gt;&gt;';

		$config['prev_link'] = '&lt;&lt;';

		$config['cur_tag_open'] = '<a href="#" class="current">';

		$config['cur_tag_close'] = '</a>';

		$config['uri_segment'] = 4;

		$config['num_links'] = 2;

		$config['total_rows'] = $this->Mproduct->count_prod_from_cate($id);

		$config['per_page'] = $limit;
		

		$this->pagination->initialize($config);

    if (empty($page))	$page = 0; //default value
	 $data['page'] = str_replace('&nbsp;', '', $this->pagination->create_links());
		$data['title']='Sản phẩm';
			$data['main']='productpage';
		$data['result']= $this->Mproduct->get_prod_cat($id,$lang);
		$this->load->view('template/index',$data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */